<?php

/**
 * model_duty
 */

class Model_duty extends YOU {

	public function __construct()
	{
		parent::__construct();
	}

	/** 读取当前boxid **/
	public function getBox($semester_id)
	{
		$row = $this->db->fetchRow("SELECT box_id FROM `tbl_duty` WHERE semester_id='{$semester_id}' ORDER BY box_id DESC");
		$box_id = (int)$row['box_id'];

		return $box_id;
	}

	/** 根据boxid得到列表 **/
	public function getAllByBox($box_id)
	{
		$duty_lists = $this->db->fetchAll("SELECT * FROM `tbl_duty` WHERE box_id='{$box_id}'");

		return $duty_lists;
	}
	
	/** 生效时间列表 **/
	public function getStartList()
	{
		$duty_lists = $this->db->fetchAll("SELECT box_id,start_time FROM `tbl_duty` ORDER BY box_id ASC");
		foreach ($duty_lists as $key => $value){
			$data[$value['start_time']] = $value['box_id'];		
		}
	
		return $data;
	}	

	/** 读取列表 **/
	public function getAll($field = "*")
	{
		$duty_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_duty` ");

		return $duty_lists;
	}


}



?>